/**
 * 
 */
let mlocation;
let uVue = new Vue({
	el:'#hSpace',
	data:{
		hpwd:'',
		nhpwd:'',
		resumeList:[],
		options:[{
			value:'包三餐'
		},
		{
			value:'福利多'
		},
		{
			value:'氛围棒'
		},
		{
			value:'弹性工时'
		},
		{
			value:'奖金'
		},
		{
			value:'高薪'
		},
		{
			value:'朝九晚五'
		},
		{
			value:'可转正'
		}
		
		],
		showdiv:[
			{isshow:true},
			{isshow:false},
			{isshow:false},
			{isshow:false},
			{isshow:false},
		],
		pushjob:{
			bid:'',
			batchid:'',
			jobname:'',
			jobdetails:'',
			welfare:'',
			jeducation:'',
			jsalary:'',
			jnumber:'',
			jtime:'',
			jptime:null
		},
		jobList:[],
		userD:{},
		imageUrl:'',
		uimg:null,
		npwd:'',
		opwd:'',
		userDtable:[
			{isM:true,isEnable:false},
			{isM:true,isEnable:false},
			{isM:true,isEnable:false},
			{isM:true,isEnable:false},
			{isM:true,isEnable:false},
			{isM:true,isEnable:false},
		],
		interest:[],
		interestList:[],
		pickerOptions: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date());
            }
          }]
        }
	
	},
	created(){
		
		let _this = this;
			axios.post('/usert/interest')
				 .then((response)=>{
					_this.interestList = response.data;
					console.log(response.data);
					
				}).catch(error=>{
					console.log("error:"+error);
				});
		mlocation = window.location.href;
		let hid = mlocation.split('=')[1];
		console.log(mlocation+"--"+hid);
		let data = new FormData();
		data.append("hid",hid);
		axios.post('/hrt/getone',data)
				.then(success=>{
					this.userD = success.data;
					//this.interest = this.userD.uinterest.split(',');
					console.log("hr信息"+this.userD.bid);
					this.getJobByhr(this.userD.bid,this.userD.batchid);
					this.getResumeByhr(this.userD.hid);
				}).catch(error=>{
					console.log("error");
				});
	
	},
	methods:{
		logout(){
			let logoutBtn = document.getElementById("log");
			logoutBtn.click();
		},
		update(){
			let data = new FormData();
		data.append("hid",this.userD.hid);
		data.append("hpwd",this.nhpwd);
			axios.post("/hrt/update",data).then(resp=>{
				if(resp.data>0)
					{
						this.$message.success("密码修改成功,请重新登录");
						
						setTimeout(()=>{
							let b = document.getElementById("log");
						b.click();
						},1000);
					}
			}).catch();
		},
		reject(rfid){
			axios.get('/hrt/alterstatunot',{
				params:{
					rfid:rfid
				}
			}).then(resp=>{
				this.$message("已通知该用户");
			}).catch();
		},
		go(rfid){
			axios.get('/hrt/alterstatupass',{
				params:{
					rfid:rfid
				}
			}).then(resp=>{
				this.$message("已通知该用户");
			}).catch();
		},
		changeAndload(rfid,path){
			
	    let a = document.createElement('a')
	    a.href ="/hrt/dloadresume?path="+path;
	    a.click();
		let data = new FormData();
		data.append("rfid",rfid);
		axios.post('/hrt/alterstatuing',data).then(resp=>{
			console.log(resp.data);
		}).catch();
		},
		submitJob(){

			let data = new FormData();
			data.append("bid",this.userD.bid);
			data.append("batchid",this.userD.batchid);
			data.append("jobname",this.pushjob.jobname);
			data.append("jobdetails",this.pushjob.jobdetails);
			data.append("welfare",this.pushjob.welfare);
			data.append("jeducation",this.pushjob.jeducation);
			data.append("jsalary",this.pushjob.jsalary);
			data.append("jnumber",this.pushjob.jnumber);
			data.append("jtime",this.pushjob.jtime);
			data.append("jptime",this.pushjob.jptime);
			axios.post('/job/add',data).then(resp=>{
				this.$message.success("职位发布成功");
				console.log(resp.data);
			}).catch();
		},
		getResumeByhr(hid){
			let data = new FormData();
			data.append("hid",hid);
			axios.post('/hrt/getresume',data).then(resp=>{
				this.resumeList = resp.data;
				console.log("简历信息："+this.resumeList);
			}).catch(error=>{
				console.log(error);
			});
		},
		getJobByhr(bid,batchid){
			let data = new FormData();
			let _this = this;
			data.append("bid",bid);
			data.append("batchid",batchid);
			console.log(this.userD.bid+"-"+this.userD.batchid);
			axios.post('/job/getByhr',data).then(resp=>{
				_this.jobList = resp.data;
				console.log(resp.data+'22');
			}).catch(error=>{
				console.log(error);
			});
		},
		show(index){
			for(let i = 0;i<this.showdiv.length;i++){
				if(i===index){
					this.showdiv[i].isshow = true;
				}
				else{
					this.showdiv[i].isshow = false;
				}
				
			}
			
		},
		uploadUserImg(item){
			//console.log(item);
			this.imageUrl = URL.createObjectURL(item.file);//blobUrl
			this.userDtable[5].isEnable = true;
			console.log(this.imageUrl);
			this.uimg = item.file;
		},
        beforeAvatarUpload(file) {
	        const isJPG = file.type === 'image/jpeg';
	        const isLt2M = file.size / 1024 / 1024 < 2;
	
	        if (!isJPG) {
	          this.$message.error('上传头像图片只能是 JPG 格式!');
	        }
	        if (!isLt2M) {
	          this.$message.error('上传头像图片大小不能超过 2MB!');
	        }
	        return isJPG && isLt2M;
      },
		
			
		
	}
});